

import uuid
import struct

import time
import random

from common.datetime_ import get_timestamp_us


def get_uuid64():
    '''
    获取64位uuid
    '''
    my_uuid = uuid.uuid4()
    binary_uuid = my_uuid.bytes
    uuid64 = int.from_bytes(binary_uuid[:8], byteorder='big')
    return uuid64


def get_fake_uuid():
    '''
    获取类uuid的id，使用时间戳+uuid64，在满足基本需求的基础上，避免uuid过长的问题
    '''
    timestamp_us = get_timestamp_us()
    uuid64 = get_uuid64()
    unique_id = f"{timestamp_us}{uuid64}"
    return unique_id


if __name__ == "__main__":
    res = get_fake_uuid()
    print(res)
